﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataEquipmentStateRecord" @search="()=>{getTableDataEquipmentStateRecord();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LineId_FormItem" prop="LineId" :label="$t('message.autotrans._Model_EquipmentStateRecord_LineId')">
            <el-input v-model="searchDataEquipmentStateRecord.LineId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LineName_FormItem" prop="LineName" :label="$t('message.autotrans._Model_EquipmentStateRecord_LineName')">
            <el-input v-model="searchDataEquipmentStateRecord.LineName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProuductId_FormItem" prop="ProuductId" :label="$t('message.autotrans._Model_EquipmentStateRecord_ProuductId')">
            <el-input v-model="searchDataEquipmentStateRecord.ProuductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductName_FormItem" prop="ProductName" :label="$t('message.autotrans._Model_EquipmentStateRecord_ProductName')">
            <el-input v-model="searchDataEquipmentStateRecord.ProductName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipmentId_FormItem" prop="EquipmentId" :label="$t('message.autotrans._Model_EquipmentStateRecord_Equipment')">
            <el-select v-model="searchDataEquipmentStateRecord.EquipmentId" clearable>
               <el-option v-for="item in stateEquipmentStateRecord.AllEquipments" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipName_FormItem" prop="EquipName" :label="$t('message.autotrans._Model_EquipmentStateRecord_EquipName')">
            <el-input v-model="searchDataEquipmentStateRecord.EquipName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Status_FormItem" prop="Status" :label="$t('message.autotrans._Model_EquipmentStateRecord_Status')">
            <el-select v-model="searchDataEquipmentStateRecord.Status" clearable>
               <el-option key="Running" value="Running" :label="$t('message.autotrans._Enum_EquipStatusEnum_Running')"></el-option>
               <el-option key="Warning" value="Warning" :label="$t('message.autotrans._Enum_EquipStatusEnum_Warning')"></el-option>
               <el-option key="EStop" value="EStop" :label="$t('message.autotrans._Enum_EquipStatusEnum_EStop')"></el-option>
               <el-option key="Offline" value="Offline" :label="$t('message.autotrans._Enum_EquipStatusEnum_Offline')"></el-option>
               <el-option key="Maintenance" value="Maintenance" :label="$t('message.autotrans._Enum_EquipStatusEnum_Maintenance')"></el-option>
               <el-option key="Repair" value="Repair" :label="$t('message.autotrans._Enum_EquipStatusEnum_Repair')"></el-option>
               <el-option key="Manual" value="Manual" :label="$t('message.autotrans._Enum_EquipStatusEnum_Manual')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StartTime_FormItem" prop="StartTime" :label="$t('message.autotrans._Model_EquipmentStateRecord_StartTime')">
            <el-date-picker v-model="searchDataEquipmentStateRecord.StartTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EndTime_FormItem" prop="EndTime" :label="$t('message.autotrans._Model_EquipmentStateRecord_EndTime')">
            <el-date-picker v-model="searchDataEquipmentStateRecord.EndTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Duration_FormItem" prop="Duration" :label="$t('message.autotrans._Model_EquipmentStateRecord_Duration')">
            <el-input v-model="searchDataEquipmentStateRecord.Duration" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ActiveOee_FormItem" prop="ActiveOee" :label="$t('message.autotrans._Model_EquipmentStateRecord_ActiveOee')">
            <el-select v-model="searchDataEquipmentStateRecord.ActiveOee" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/EquipmentManagement/EquipmentStateRecord/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentStateRecord/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentStateRecord/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentStateRecord/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentStateRecord/EquipmentStateRecordExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefEquipmentStateRecord" v-bind="tableDataEquipmentStateRecord">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/EquipmentManagement/EquipmentStateRecord/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/EquipmentStateRecord/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/EquipmentStateRecord/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipmentStateRecordIndex;true;Digitalmes.EquipmentManagement.Controllers;EquipmentStateRecord">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipmentstaterecordApi } from '/@/api/equipmentmanagement/equipmentstaterecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateEquipmentStateRecord = reactive({
    
    AllEquipments: [] as any[],
});

const searchDataEquipmentStateRecord = ref({
        LineId: null,
        LineName: '',
        ProuductId: null,
        ProductName: '',
        EquipmentId: null,
        EquipName: '',
        Status: undefined,
        StartTime: undefined,
        EndTime: undefined,
        Duration: null,
        ActiveOee: undefined,
});

// 定义变量内容
const tableRefEquipmentStateRecord = ref();
const tableDataEquipmentStateRecord = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page产线编号'),key: 'EquipmentStateRecord_LineId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产线名称'),key: 'EquipmentStateRecord_LineName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品'),key: 'EquipmentStateRecord_ProuductId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品名称'),key: 'EquipmentStateRecord_ProductName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备'),key: 'EquipmentStateRecord_Equipment',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备名称'),key: 'EquipmentStateRecord_EquipName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备状态'),key: 'EquipmentStateRecord_Status',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page开始时间'),key: 'EquipmentStateRecord_StartTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page结束时间'),key: 'EquipmentStateRecord_EndTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page持续时长'),key: 'EquipmentStateRecord_Duration',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.PageOEE激活'),key: 'EquipmentStateRecord_ActiveOee',type: 'switch',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataEquipmentStateRecord = () => {
    tableRefEquipmentStateRecord.value.doSearch(equipmentstaterecordApi().search, searchDataEquipmentStateRecord.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataEquipmentStateRecord)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataEquipmentStateRecord)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataEquipmentStateRecord)
};

// 删除
const onDelete = (row: any) => {
    equipmentstaterecordApi().delete([row.ID]).then(() => { getTableDataEquipmentStateRecord()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefEquipmentStateRecord.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      equipmentstaterecordApi().delete(selectedids).then(() => { getTableDataEquipmentStateRecord()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefEquipmentStateRecord.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataEquipmentStateRecord)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataEquipmentStateRecord)
};

const onExport = () => {
	const selected = tableRefEquipmentStateRecord.value.getSelectedRows();
	if (selected.length > 0) {
		equipmentstaterecordApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		equipmentstaterecordApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/EquipmentManagement/EquipmentStateRecord/GetEquipments',[],false).then(x=>{stateEquipmentStateRecord.AllEquipments = x});
        getTableDataEquipmentStateRecord();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

